#ifndef MTEXTEDITER_H
#define MTEXTEDITER_H
#include <QPlainTextEdit>
#include <QPainter>
#include <QPaintEvent>
#include <QTextBlock>
#include "../../unitls/globalsignalmgr.h"
#include "../../settings/hotkey.h"

class LineNumArea;

class MPlainTextEditer:public QPlainTextEdit
{
    Q_OBJECT
public:
    MPlainTextEditer(QWidget *parent = 0);

    void lineNumberAreaPaintEvent(QPaintEvent *event);
    int lineNumberAreaWidth();

protected:
    void resizeEvent(QResizeEvent *event) override;
    void keyPressEvent(QKeyEvent *e);
private slots:
    void updateLineNumberAreaWidth(int newBlockCount);
    void highlightCurrentLine();
    void updateLineNumberArea(const QRect &, int);

private:
    QWidget *lineNumberArea;
};
class LineNumArea:public QWidget{
    Q_OBJECT
public:
    LineNumArea(MPlainTextEditer *editor);

    QSize sizeHint() const override;

protected:
    void paintEvent(QPaintEvent *event) override;

private:
    MPlainTextEditer *codeEditor;
};
#endif // MTEXTEDITER_H
